package c.e.a.b.e.c;

import java.io.IOException;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.logging.Logger;

/* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
public final class u6 {
    public static final Class<?> a;
    public static final f7<?, ?> b = e(false);
    public static final f7<?, ?> c = e(true);
    public static final f7<?, ?> d = new h7();

    static {
        Class cls;
        try {
            cls = Class.forName("com.google.protobuf.GeneratedMessage");
        } catch (Throwable unused) {
            cls = null;
        }
        a = cls;
    }

    public static void A(int i, List<Long> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.K(((Long) list.get(i)).longValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.m(e4.R(((Long) list.get(i2)).longValue()));
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.g(i, e4.R(((Long) list.get(i2)).longValue()));
                i2++;
            }
        }
    }

    public static int B(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + C(list);
    }

    public static int C(List<Integer> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof x4) {
            x4 x4Var = (x4) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.L(x4Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.L(((Integer) list.get(i)).intValue());
                i++;
            }
        }
        return i2;
    }

    public static void D(int i, List<Long> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Long) list.get(i)).longValue();
                    Logger logger = e4.b;
                    i3 += 8;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.A(((Long) list.get(i2)).longValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.z(i, ((Long) list.get(i2)).longValue());
                i2++;
            }
        }
    }

    public static int E(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + F(list);
    }

    public static int F(List<Integer> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof x4) {
            x4 x4Var = (x4) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.O(x4Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.O(((Integer) list.get(i)).intValue());
                i++;
            }
        }
        return i2;
    }

    public static void G(int i, List<Long> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Long) list.get(i)).longValue();
                    Logger logger = e4.b;
                    i3 += 8;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.A(((Long) list.get(i2)).longValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.z(i, ((Long) list.get(i2)).longValue());
                i2++;
            }
        }
    }

    public static int H(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return e4.S(i) * size;
    }

    public static int I(List<?> list) {
        return list.size() << 2;
    }

    public static void J(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.H(((Integer) list.get(i)).intValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.e(((Integer) list.get(i2)).intValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.s(i, ((Integer) list.get(i2)).intValue());
                i2++;
            }
        }
    }

    public static int K(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return e4.N(i) * size;
    }

    public static int L(List<?> list) {
        return list.size() << 3;
    }

    public static void M(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.L(((Integer) list.get(i)).intValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.r(((Integer) list.get(i2)).intValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.y(i, ((Integer) list.get(i2)).intValue());
                i2++;
            }
        }
    }

    public static void N(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.O(((Integer) list.get(i)).intValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.r(e4.V(((Integer) list.get(i2)).intValue()));
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.y(i, e4.V(((Integer) list.get(i2)).intValue()));
                i2++;
            }
        }
    }

    public static void O(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Integer) list.get(i)).intValue();
                    Logger logger = e4.b;
                    i3 += 4;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.C(((Integer) list.get(i2)).intValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.G(i, ((Integer) list.get(i2)).intValue());
                i2++;
            }
        }
    }

    public static void P(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Integer) list.get(i)).intValue();
                    Logger logger = e4.b;
                    i3 += 4;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.C(((Integer) list.get(i2)).intValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.G(i, ((Integer) list.get(i2)).intValue());
                i2++;
            }
        }
    }

    public static void Q(int i, List<Integer> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.H(((Integer) list.get(i)).intValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.e(((Integer) list.get(i2)).intValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.s(i, ((Integer) list.get(i2)).intValue());
                i2++;
            }
        }
    }

    public static void R(int i, List<Boolean> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Boolean) list.get(i)).booleanValue();
                    Logger logger = e4.b;
                    i3++;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.d((byte) ((Boolean) list.get(i2)).booleanValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.l(i, ((Boolean) list.get(i2)).booleanValue());
                i2++;
            }
        }
    }

    public static int a(int i, Object obj, s6 s6Var) {
        if (obj instanceof j5) {
            j5 j5Var = (j5) obj;
            i = e4.L(i << 3);
            int a = j5Var.a();
            return (e4.L(a) + a) + i;
        }
        e6 e6Var = (e6) obj;
        return e4.c(e6Var, s6Var) + e4.L(i << 3);
    }

    public static int b(int i, List<?> list) {
        int size = list.size();
        int i2 = 0;
        if (size == 0) {
            return 0;
        }
        i = e4.D(i) * size;
        Object u;
        int p;
        if (list instanceof l5) {
            l5 l5Var = (l5) list;
            while (i2 < size) {
                u = l5Var.u(i2);
                if (u instanceof t3) {
                    p = e4.p((t3) u);
                } else {
                    p = e4.q((String) u);
                }
                i = p + i;
                i2++;
            }
        } else {
            while (i2 < size) {
                u = list.get(i2);
                if (u instanceof t3) {
                    p = e4.p((t3) u);
                } else {
                    p = e4.q((String) u);
                }
                i = p + i;
                i2++;
            }
        }
        return i;
    }

    public static int c(int i, List<?> list, s6 s6Var) {
        int size = list.size();
        int i2 = 0;
        if (size == 0) {
            return 0;
        }
        i = e4.D(i) * size;
        while (i2 < size) {
            int b;
            Object obj = list.get(i2);
            if (obj instanceof j5) {
                b = e4.b((j5) obj);
            } else {
                b = e4.c((e6) obj, s6Var);
            }
            i += b;
            i2++;
        }
        return i;
    }

    public static int d(List<Long> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof s5) {
            s5 s5Var = (s5) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.F(s5Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.F(((Long) list.get(i)).longValue());
                i++;
            }
        }
        return i2;
    }

    public static f7<?, ?> e(boolean z) {
        Class cls;
        try {
            cls = Class.forName("com.google.protobuf.UnknownFieldSetSchema");
        } catch (Throwable unused) {
            cls = null;
        }
        if (cls == null) {
            return null;
        }
        try {
            return (f7) cls.getConstructor(new Class[]{Boolean.TYPE}).newInstance(new Object[]{Boolean.valueOf(z)});
        } catch (Throwable unused2) {
            return null;
        }
    }

    public static void f(int i, List<String> list, x7 x7Var) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (list instanceof l5) {
                l5 l5Var = (l5) list;
                while (i2 < list.size()) {
                    Object u = l5Var.u(i2);
                    if (u instanceof String) {
                        g4Var.a.k(i, (String) u);
                    } else {
                        g4Var.a.h(i, (t3) u);
                    }
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.k(i, (String) list.get(i2));
                i2++;
            }
        }
    }

    public static void g(int i, List<?> list, x7 x7Var, s6 s6Var) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            for (int i2 = 0; i2 < list.size(); i2++) {
                g4Var.a.j(i, (e6) list.get(i2), s6Var);
            }
        }
    }

    public static void h(int i, List<Double> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            double doubleValue;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Double) list.get(i)).doubleValue();
                    Logger logger = e4.b;
                    i3 += 8;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    e4 e4Var = g4Var.a;
                    doubleValue = ((Double) list.get(i2)).doubleValue();
                    Objects.requireNonNull(e4Var);
                    e4Var.A(Double.doubleToRawLongBits(doubleValue));
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                e4 e4Var2 = g4Var.a;
                doubleValue = ((Double) list.get(i2)).doubleValue();
                Objects.requireNonNull(e4Var2);
                e4Var2.z(i, Double.doubleToRawLongBits(doubleValue));
                i2++;
            }
        }
    }

    public static <T, FT extends p4<FT>> void i(j4<FT> j4Var, T t, T t2) {
        n4 b = j4Var.b(t2);
        if (!b.a.isEmpty()) {
            n4 f = j4Var.f(t);
            Objects.requireNonNull(f);
            for (int i = 0; i < b.a.e(); i++) {
                f.j(b.a.d(i));
            }
            for (Entry j : b.a.g()) {
                f.j(j);
            }
        }
    }

    public static boolean j(Object obj, Object obj2) {
        return obj == obj2 || (obj != null && obj.equals(obj2));
    }

    public static int k(int i, List list) {
        if (list.size() == 0) {
            return 0;
        }
        return (e4.D(i) * list.size()) + d(list);
    }

    public static int l(int i, List<t3> list) {
        int size = list.size();
        int i2 = 0;
        if (size == 0) {
            return 0;
        }
        i = e4.D(i) * size;
        while (i2 < list.size()) {
            i += e4.p((t3) list.get(i2));
            i2++;
        }
        return i;
    }

    public static int m(int i, List<e6> list, s6 s6Var) {
        int size = list.size();
        int i2 = 0;
        if (size == 0) {
            return 0;
        }
        int i3 = 0;
        while (i2 < size) {
            i3 += e4.x(i, (e6) list.get(i2), s6Var);
            i2++;
        }
        return i3;
    }

    public static int n(List<Long> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof s5) {
            s5 s5Var = (s5) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.F(s5Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.F(((Long) list.get(i)).longValue());
                i++;
            }
        }
        return i2;
    }

    public static void o(int i, List<t3> list, x7 x7Var) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            for (int i2 = 0; i2 < list.size(); i2++) {
                g4Var.a.h(i, (t3) list.get(i2));
            }
        }
    }

    public static void p(int i, List<?> list, x7 x7Var, s6 s6Var) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            for (int i2 = 0; i2 < list.size(); i2++) {
                g4Var.e(i, list.get(i2), s6Var);
            }
        }
    }

    public static void q(int i, List<Float> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    ((Float) list.get(i)).floatValue();
                    Logger logger = e4.b;
                    i3 += 4;
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    e4 e4Var = g4Var.a;
                    float floatValue = ((Float) list.get(i2)).floatValue();
                    Objects.requireNonNull(e4Var);
                    e4Var.C(Float.floatToRawIntBits(floatValue));
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                e4 e4Var2 = g4Var.a;
                float floatValue2 = ((Float) list.get(i2)).floatValue();
                Objects.requireNonNull(e4Var2);
                e4Var2.G(i, Float.floatToRawIntBits(floatValue2));
                i2++;
            }
        }
    }

    public static int r(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + n(list);
    }

    public static int s(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + t(list);
    }

    public static int t(List<Long> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof s5) {
            s5 s5Var = (s5) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.K(s5Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.K(((Long) list.get(i)).longValue());
                i++;
            }
        }
        return i2;
    }

    public static void u(int i, List<Long> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.F(((Long) list.get(i)).longValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.m(((Long) list.get(i2)).longValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.g(i, ((Long) list.get(i2)).longValue());
                i2++;
            }
        }
    }

    public static int v(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + w(list);
    }

    public static int w(List<Integer> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof x4) {
            x4 x4Var = (x4) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.H(x4Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.H(((Integer) list.get(i)).intValue());
                i++;
            }
        }
        return i2;
    }

    public static void x(int i, List<Long> list, x7 x7Var, boolean z) throws IOException {
        if (list != null && !list.isEmpty()) {
            g4 g4Var = (g4) x7Var;
            Objects.requireNonNull(g4Var);
            int i2 = 0;
            if (z) {
                g4Var.a.f(i, 2);
                int i3 = 0;
                for (i = 0; i < list.size(); i++) {
                    i3 += e4.F(((Long) list.get(i)).longValue());
                }
                g4Var.a.r(i3);
                while (i2 < list.size()) {
                    g4Var.a.m(((Long) list.get(i2)).longValue());
                    i2++;
                }
                return;
            }
            while (i2 < list.size()) {
                g4Var.a.g(i, ((Long) list.get(i2)).longValue());
                i2++;
            }
        }
    }

    public static int y(int i, List list) {
        int size = list.size();
        if (size == 0) {
            return 0;
        }
        return (e4.D(i) * size) + z(list);
    }

    public static int z(List<Integer> list) {
        int size = list.size();
        int i = 0;
        if (size == 0) {
            return 0;
        }
        int i2;
        if (list instanceof x4) {
            x4 x4Var = (x4) list;
            i2 = 0;
            while (i < size) {
                i2 += e4.H(x4Var.d(i));
                i++;
            }
        } else {
            i2 = 0;
            while (i < size) {
                i2 += e4.H(((Integer) list.get(i)).intValue());
                i++;
            }
        }
        return i2;
    }
}
